package com.yuanxiao.common.core.utils;

import java.math.BigDecimal;

/**
 * Author: cg
 * Date: 2023/2/19 15:42
 * Content:
 */
public class PointUtils {
    public static long getDistance(double latitude,double longitude,double latitude1,double longitude1){
        Point p1 = new Point();
        p1.x = latitude;
        p1.y = longitude;
        Point p2 = new Point();
        p2.x = latitude1;
        p2.y = longitude1;
        return BigDecimal.valueOf(p1.getDistance(p2)).setScale(2, BigDecimal.ROUND_HALF_UP).abs().longValue();
    }


}

class Point{
    double x;
    double y;
    public double getDistance(Point p){
        double xAbs = BigDecimal.valueOf(p.x-x).abs().doubleValue();
        double yAbs = BigDecimal.valueOf(p.y-y).abs().doubleValue();
        return Math.sqrt(Math.abs((p.x - x)* (p.x - x)+(p.y-y)* (p.y-y)))*1000;
    }
}

